﻿using eProcurement.DAL;
using eProcurement.helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace eProcurement.controls
{
    public partial class CompanyItemControl : System.Web.UI.UserControl
    {
        protected void Page_Load( object sender, EventArgs e )
        {

        }

        public void Setup( Purchaser purchaser )
        {
            projectlink.Attributes.Add( "href", "../members/OpenBids.aspx?type=company&action=" + purchaser.Id );
            lblCompany.InnerText = purchaser.CompanyName;
            lblOpenProjects.InnerText = purchaser.NumberOpenProjects.ToString();
            if ( purchaser.Description.Length > 200 )
            {
                lblOverview.InnerText = purchaser.Description.Substring( 0, 200 ) + "...";
            }
            else
            {
                lblOverview.InnerText = purchaser.Description;
            }
            lblWebsite.InnerText = purchaser.Website;
            lblWebsite.Attributes.Add( "href", SiteFormatter.FormatURL( purchaser.Website ) );
        }
    }
}